package kotlindemo.com.project

import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
import android.widget.Toast
import kotlindemo.com.kotlindemo.R
import kotlindemo.com.project.adapter.ForeCastListAdapter
import kotlindemo.com.project.request.Request
import kotlinx.android.synthetic.main.activity_home.*

class HomeActivity : AppCompatActivity() {
    private val items = listOf("Mon 6/23 - Sunny - 31/17",
            "Tue 6/24 - Foggy - 21/8",
            "Wed 6/25 - Cloudy - 22/17",
            "Thurs 6/26 - Rainy - 18/11",
            "Fri 6/27 - Foggy - 21/10",
            "Sat 6/28 - TRAPPED IN WEATHERSTATION - 23/18",
            "Sun 6/29 - Sunny - 20/7")
    private val url = ""
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_home)
        val ryList: RecyclerView = findViewById(R.id.ry_list)
        ryList.layoutManager = LinearLayoutManager(this)
        ryList.adapter = ForeCastListAdapter(items)
        toast("你好")
        val request = Request(url)
//        val button: Button = findViewById(R.id.button)
        button.setOnClickListener {
            val intent = Intent();
            intent.setClass(this, DatePickerActivity::class.java)
            startActivity(intent)
        }
    }

    fun Context.toast(message: CharSequence, duration: Int = Toast.LENGTH_SHORT) {
        Toast.makeText(this, message, duration).show()
    }
}
